package lab3p3;

import java.awt.Graphics;

import javax.swing.JFrame;

/**
 * Title: Lab3TriangleAndButton class for CSIS 235 Lab 3
 * Description: CS 235 Lab #3
 *    Basic GUI class that uses a JButton object to decide when to draw a triangle.
 * 
 * @author Anthony Varghese
 * @email anthony.varghese@my.uwrf.edu
 * @date September 3rd 2014
 * @version 1.0
 */

public class Lab3TriangleAndButton extends JFrame {

	/**
	 * main - this is where the program starts
	 * @param args
	 */
	public static void main(String[] args) {
		Lab3TriangleAndButton window = new Lab3TriangleAndButton("Triangle");

	}

	/**
	 * Class data members:
	 * Default serial version id
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Instance data members
	 */
	private boolean draw_triangle = true;
	
	
	/**
	 * Constructor with a String to be used as the title
	 * @param string
	 */
	public Lab3TriangleAndButton(String title) {
		setTitle( title );
		setBounds( 100, 100, 400, 300);
		
		setDefaultCloseOperation( EXIT_ON_CLOSE );
		setVisible(true);
	}

	/**
	 * 
	 * paint method - this gets called whenever the window has to be "refreshed"
	 * Notice that it is not called anywhere in this program.
	 * 
	 * @see java.awt.Window#paint(java.awt.Graphics)
	 */
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		
		if (draw_triangle){
			g.drawLine( 100, 200, 200, 200);
			g.drawLine( 200, 200, 150, 100);
			g.drawLine( 150, 100, 100, 200);
		}
	}
	
}
